package com.cjl.learn.factory.simpleFactory.order;

import com.cjl.learn.factory.simpleFactory.factory.PizzaFactory;
import com.cjl.learn.factory.simpleFactory.pizza.Pizza;

/**
 * Created by Enzo Cotter on 2019-08-14.
 */
public class PizzaOrderSystem {

    private PizzaFactory pizzaFactory;

    public PizzaOrderSystem(PizzaFactory pizzaFactory) {
        this.pizzaFactory = pizzaFactory;
    }

    public Pizza orderPizza(String type) {
        Pizza pizza = pizzaFactory.createPizza(type);
        if (null == pizza) {
            System.out.println("厨师正在研制" + type + "pizza, 敬请期待");
            return null;
        }
        pizza.prepare();
        pizza.bake();
        pizza.cut();
        pizza.box();
        return pizza;
    }
}
